//此函数链接两个字符数组
#include <stdio.h>

int main(int argc, char const *argv[])
{
  void concat(char result[], const char str1[], int n1, const char str2[], int n2);
  const char s1[5] = {'T', 'e', 's', 't', ' '};
  const char s2[6] = {'w', 'o', 'r', 'k', 's', '.'};
  char s3[11];
  int i;
  concat(s3, s1, 5, s2, 6);
  for (i = 0; i < 11; i++)
  {
    printf("%c", s3[i]);
  }
  printf("\n");
  return 0;
}
void concat(char result[], const char str1[], int n1, const char str2[], int n2)
{
  int i, j;
  //将str1复制到result中
  for (i = 0; i < n1; i++)
  {
    result[i] = str1[i];
  }
  //将str2复制到res;ult中
  for (j = 0; j < n2; j++)
  {
    result[n1 + j] = str2[j];
  }
}
